<?
        $results = array();
        require_once('../inc/paymentmethods.php');
        if(isset($_POST['id']))
        {
                $row = $_POST;
                $results = ValidatePaymentMethod($row);
                if($results === true)
                        $results = SavePaymentMethod($row);
                if($results === true)
                {
                        if(isset($_REQUEST['ajax'])){
                                $rs = GetPaymentMethod($row['id']);
                                include('item.php');
                        }else{
                                header("Location: index.php?inserted=$row[id]#inserted");
                        }
                        die();
                }
        }else{
                if(isset($_REQUEST['id']))
                        $row = GetPaymentMethod($_REQUEST['id']);
                else
                        $row = BlankPaymentMethod();
        }
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Details of Payment Method: <?=$row['Description']?></title>
    <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css">
    <link rel="stylesheet" type="text/css" href="../inc/bootstrap.css">
    <style type="text/css" >
        .error { color: red; }
                input.error { border-color: red; }
    </style>
</head>

<body>
		<? print_r($row); ?>
        <? include('../inc/header.php'); ?>
        <div class="container">
                        <? include('../inc/nav.php'); ?>
            <div id="contents">
               
                <dl class="error">
                        <? foreach ($results as $key => $value): ?>
                                                <dt><?=$key?></dt>
                                                <dd><?=$value?></dd>
                                        <? endforeach; ?>
                </dl>
               
                <form class="form-horizontal" method="post" action="edit.php">
                    <div class=" control-group">
                        <label class="control-label" for="Description">Description:</label>
                        <div class="controls">
                            <input      type="text" name="Description" id="Description" value="<?=$row['Description']?>"
                                                                        class="required  <?=isset($results['Description']) ? 'error' : '' ?>"
                                                         />
                             <span class="error"><?=isset($results['Description']) ? $results['Description'] : '' ?></span>
                        </div>
                    </div>
                    
                    <div class="control-group">
                        <div class="controls">
                            <input type="hidden" name="id" value="<?=$row['id']?>" />
                                <input class="btn btn-primary" type="submit" value="Save" />
                            <a href="./" class="cancel-link">Cancel</a>
                        </div>
                    </div>
                </form>
           </div>
       </div>
       <script type="application/javascript" src="http://code.jquery.com/ui/1.9.1/jquery-ui.js">
           </script>
       <script type="application/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js">
           </script>
       <script type="text/javascript">
                        $(function(){
                                //$("#Keyword_id").val('<?=$row['Description']?>');
                                $("input[type='date']").datepicker();
                               
                                $("form").validate({
                                        rules: {
                                                UserType_id: { required: true }
                                        }
                                });
                               
                        });
           </script>
</body>
</html>
